package com.ruoyi.zhike.controller.system;

import java.util.List;
import java.util.Map;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.AppEncrypt;
import com.ruoyi.zhike.system.service.IAppEncryptService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.AppEncryptWrapper;

/**
 * app加密配置Controller
 * 
 * @author ruoyi
 * @date 2024-04-17
 */
@RestController
@RequestMapping("/system/encrypt")
public class AppEncryptController extends BaseController
{
    @Autowired
    private IAppEncryptService appEncryptService;

    /**
    *
    */
    @GetMapping("/extData")
    public AjaxResult extData() {
        JSONObject returnData = new JSONObject();

        return AjaxResult.success(returnData);
    }

    /**
     * 查询app加密配置列表
     */
    @RequiresPermissions("system:encrypt:list")
    @GetMapping("/list")
    public TableDataInfo list(AppEncrypt appEncrypt)
    {
        startPage();
        List<Map<String, Object>> list = appEncryptService.selectAppEncryptListMap(appEncrypt);
        list = new AppEncryptWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出app加密配置列表
     */
    @RequiresPermissions("system:encrypt:export")
    @Log(title = "app加密配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppEncrypt appEncrypt)
    {
        List<AppEncrypt> list = appEncryptService.selectAppEncryptList(appEncrypt);
        ExcelUtil<AppEncrypt> util = new ExcelUtil<AppEncrypt>(AppEncrypt.class);
        util.exportExcel(response, list, "app加密配置数据");
    }

    /**
     * 获取app加密配置详细信息
     */
    @RequiresPermissions("system:encrypt:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(appEncryptService.selectAppEncryptById(id));
    }

    /**
     * 新增app加密配置
     */
    @RequiresPermissions("system:encrypt:add")
    @Log(title = "app加密配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppEncrypt appEncrypt)
    {
        return toAjax(appEncryptService.insertAppEncrypt(appEncrypt));
    }

    /**
     * 修改app加密配置
     */
    @RequiresPermissions("system:encrypt:edit")
    @Log(title = "app加密配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppEncrypt appEncrypt)
    {
        return toAjax(appEncryptService.updateAppEncrypt(appEncrypt));
    }

    /**
     * 删除app加密配置
     */
    @RequiresPermissions("system:encrypt:remove")
    @Log(title = "app加密配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(appEncryptService.deleteAppEncryptByIds(ids));
    }
}
